using UnityEngine;

namespace HybridCLR.Extension.Editor
{
    public partial class Commond
    {
        public static UnityEditor.AddressableAssets.Build.AddressableAssetBuildResult BuildAddressable()
        {
            UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent(out var result);
            return result;
        }
        
        public static void BuildAddressable(BuildParam buildParam)
        {
            if (buildParam.Result == BuildResult.Building)
            {
                UnityEditor.AddressableAssets.Settings.AddressableAssetSettings.BuildPlayerContent(out var result);
                buildParam.AddressableAssetBuildResult = result;
                if (!string.IsNullOrEmpty(result.Error))
                {
                    buildParam.Result = BuildResult.Fail;
                }
            }
        }
    }
}
